package com.yyds.oneservice.controller;


import com.yyds.common.R;
import com.yyds.oneservice.annotation.UnInterception;
import com.yyds.oneservice.pojo.CmsSubject;
import com.yyds.oneservice.service.impl.CmsSubjectServiceImpl;
import com.yyds.oneservice.service.impl.ProductServiceImpl;
import com.yyds.oneservice.vo.CmsSubjectVo;
import com.yyds.oneservice.vo.UserProductVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 专题表 前端控制器
 * </p>
 *
 * @author lxy
 * @since 2022-12-12
 */
@Api(tags = "橙信圈推荐的接口")
@RestController
@RequestMapping("/cmsSubject")
public class CmsSubjectController {
    @Autowired
    private CmsSubjectServiceImpl cmsSubjectService;

    @GetMapping("/firstshow")
    @ApiOperation(value = "萌宠展示的页面")
    @UnInterception
    public R firstshow(){
        List<CmsSubjectVo> cmsSubjects =cmsSubjectService.findByM();
        return R.ok().data("data",cmsSubjects);
    }
    @PostMapping ("/selectshow")
    @ApiOperation(value = "萌宠展示的页面-选择查询")
    @UnInterception
    public R selectshow(@RequestBody @ApiParam(name="cmsName" ,value = "专题类别必填" ,required = true) String cmsName){
        List<CmsSubjectVo> cmsSubjectVos = new ArrayList<>();
        if(cmsName.isEmpty()&&cmsName==null){
            cmsSubjectVos =cmsSubjectService.findBycmsName(cmsName);
        }else{
            cmsSubjectVos =cmsSubjectService.findByM();
        }
        return R.ok().data("data",cmsSubjectVos);
    }

}
